package com.hpu.parser;

import com.hpu.bean.Notice;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class NoticeParser {
	
	public List<Notice> parse(String parseString){
		List<Notice> notices=new ArrayList<>();
		try {
			
			JSONArray array=new JSONArray(parseString);
			for(int i=0;i<array.length();i++){
				JSONObject object=array.getJSONObject(i);
				notices.add(new Notice(object.getString("id"), object.getString("name"),object.getString("time")));
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return notices;
	}
}
